﻿namespace HZY.Api.Admin.Controllers.Systems;

/// <summary>
/// 菜单控制器
/// </summary>
[ControllerDescriptor(MenuId = "25", DisplayName = "菜单")]
public class SysMenuController(IServiceProvider serviceProvider)
    : AdminControllerBase<SysMenuService, SysMenu, int, SysMenu, SysMenuFormDto>(serviceProvider)
{
    /// <summary>
    /// 获取所有菜单
    /// </summary>
    /// <param name="search"></param>
    /// <returns></returns>
    [ActionDescriptor(DisplayName = "获取所有的菜单")]
    [HttpPost]
    public async Task<List<SysMenuDto>> GetAllAsync([FromBody] SysMenu search)
    {
        return await Service.GetAllAsync(search);
    }

    /// <summary>
    /// 复制
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [Transactional]
    [HttpPost("{id}")]
    public async Task<int> CopyMenuAsync([FromRoute] int id)
    {
        return await this.Service.CopyMenuAsync(id);
    }

    /// <summary>
    /// 获取菜单国际化json
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    public async Task<Dictionary<string, string>> GetGlobalNameJsonAsync()
    {
        return await this.Service.GetGlobalNameJsonAsync();
    }
}